Many user interfaces may allow a user to launch an application and provide a string with arguments for specifying behavior of the application. For example, a user may provide a user shell interface or command interpreter with a command to launch a word processing application by entering the name of the word processing application along with a filename as a command-line argument for specifying a file for the word processor to open. A web application may also be requested to be activated using a query string with arguments or parameters provided as part of a requested URL. Typically, the arguments or parameters are provided in an array of strings without specifying the type of the argument provided. Moreover, the arguments or parameters may not be validated before an application such as word processor or web application is activated. For instance, although an application may not accept specific types of input, there is no validation performed to verify acceptable types or values for arguments received with a request to activate an application.
A problem may arise if the application may not be able handle the type or value of an argument provided. For example, if the word processor expects an integer as a length of a stream in bytes but instead a string “ABC” is passed in, then the word processor may include appropriate conversion code that tries to convert “ABC” into an integer and also has error handling functionality and may return an error message when conversion fails. If the error handling functionality is not robust enough, then the word processor may crash. As a result, it has become the responsibility of an application developer to convert argument values provided as part of a request to activate an application from an array of strings to the appropriate type and check for invalid values. In doing so, the application developer must consider the range of unacceptable values so that the program may be robust to unexpected input.
Unfortunately, there is no infrastructure in place for an application developer to declaratively specify the type or range values of acceptable arguments that may be provided with a request to activate an application so that the arguments may be validated before the application is executed. Since such arguments may not be declared or validated prior to execution of application, a warning may not be provided to a user that an application may not accept an invalid argument. If such warning is to be provided, then it is the application that has to implement this warning in an appropriate user interface as part of their error handling code. Moreover, system security may be breached by an application that may receive invalid inputs.
What is needed is a way for declaratively specifying arguments with meta data, including their associated type and range, that can be provided in a request to activate an application and for validating such arguments before activating the application.